package week10;


import java.util.Arrays;
import java.util.Scanner;

class ArrayUtils{
	public static double findMax(double[] arr,int begin, int end) throws IllegalArgumentException{
		if(begin>=end)
			throw new IllegalArgumentException("begin:"+begin+" >= end:"+end);
		else if(begin<0)
			throw new IllegalArgumentException("begin:"+begin+" < 0");
		else if(end>arr.length)
			throw new IllegalArgumentException("end:"+end+" > arr.length");
		else{
			Arrays.sort(arr);
		}
		return arr[end-1];
	}
}
public class PTA7_3 {

	public static void main(String[] args) {
		Scanner in= new Scanner(System.in);
		int n=in.nextInt();
		double []a = new double[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextInt();
		String begin =in.next();
		while(begin!=null && begin.matches("^[-+]?[0-9]+$")){
			try{
				System.out.println(ArrayUtils.findMax(a, Integer.parseInt(begin), in.nextInt()));
			}catch(Exception e){
				System.out.println(e);
			}
			begin=in.next();
		}
			try {
		     System.out.println(ArrayUtils.class.getDeclaredMethod("findMax", double[].class,int.class,int.class));
		} catch (Exception e1) {
		}	

	}

}

